M291 R"Hepa Fan Test" P"Do you want to start the Hepa Fan Test?" S4 K{"Test","Skip","Cancel"}
if input == 1
    M99
elif input == 2
    abort "Test cancelled by user"

elif input == 0
    M106 P7 H-1 X1.0 S0
    
    var maxRpmValue = 14430
    var pauseTime = 10

    ;==== Test Fan Speed 0% ====
    if fans[7].rpm > 0
        M106 P7 S0
        M291 P{"Please wait "^ {var.pauseTime} ^" seconds for the rpm to reach the set point."} S1
        G4 S{var.pauseTime}

    if fans[7].rpm != 0
        M291 R"Error" P"The fan speed does not match the set value. Please check the fan.<br> Do you want to stop test?" S4 K{"Stop","Continue Test"}
        if input == 0
            M106 P7 S0
            M106 P7 H3 T35:90 L0.2 X{global.hepaFan}
            abort "Test cancelled by user"
    else
        M291 R"Fan speed Test" P{"Preset Fan speed: "^fans[7].requestedValue*100^"% <br> Actual Fan speed is correct"} S2

    ;==== Test Fan Speed 25% ====
    M106 P7 S63.75
    M291 P{"Please wait "^ {var.pauseTime} ^" seconds for the rpm to reach the set point."} S1
    G4 S{var.pauseTime}
    if fans[7].rpm < 3300 || fans[7].rpm > 3700
        M291 R"Error" P"The fan speed does not match the set value. Please check the fan.<br> Do you want to stop test?" S4 K{"Stop","Continue Test"}
        if input == 0
            M106 P7 S0
            M106 P7 H3 T35:90 L0.2 X{global.hepaFan}
            abort "Test cancelled by user"
    else
        M291 R"Fan speed Test" P{"Preset Fan speed: "^fans[7].requestedValue*100^"% <br>Actual Fan speed is correct"} S2


    ;==== Test Fan Speed 50% ====
    M106 P7 S127.5
    M291 P{"Please wait "^ {var.pauseTime} ^" seconds for the rpm to reach the set point."} S1
    G4 S{var.pauseTime}
    if fans[7].rpm < 6400 || fans[7].rpm > 6700
        M291 R"Error" P"The fan speed does not match the set value. Please check the fan.<br> Do you want to stop test?" S4 K{"Stop","Continue Test"}
        if input == 0
            M106 P7 S0
            M106 P7 H3 T35:90 L0.2 X{global.hepaFan}
            abort "Test cancelled by user"
    else
        M291 R"Fan speed Test" P{"Preset Fan speed: "^fans[7].requestedValue*100^"% <br>Actual Fan speed is correct"} S2


    ;==== Test Fan Speed 75% ====
    M106 P7 S191.25
    M291 P{"Please wait "^ {var.pauseTime} ^" seconds for the rpm to reach the set point."} S1
    G4 S{var.pauseTime}
    if fans[7].rpm < 9700 || fans[7].rpm > 9900
        M291 R"Error" P"The fan speed does not match the set value. Please check the fan.<br> Do you want to stop test?" S4 K{"Stop","Continue Test"}
        if input == 0
            M106 P7 S0
            M106 P7 H3 T35:90 L0.2 X{global.hepaFan}
            abort "Test cancelled by user"
    else
        M291 R"Fan speed Test" P{"Preset Fan speed: "^fans[7].requestedValue*100^" <br> Actual Fan speed is correct"} S2


    ;==== Test Fan Speed 100% ====
    M106 P7 S255
    M291 P{"Please wait "^ {var.pauseTime} ^" seconds for the rpm to reach the set point."} S1
    G4 S{var.pauseTime}
    if fans[7].rpm < 14000 || fans[7].rpm > 14700
        M291 R"Error" P"The fan speed does not match the set value. Please check the fan.<br> Do you want to stop test?" S4 K{"Stop","Continue Test"}
        if input == 0
            M106 P7 S0
            M106 P7 H3 T35:90 L0.2 X{global.hepaFan}
            abort "Test cancelled by user"
    else
        M291 R"Fan speed Test" P{"Preset Fan speed: "^fans[7].requestedValue*100^"% <br> Actual Fan speed is correct"} S2

    M106 P7 S0
    M106 P7 H3 T35:90 L0.2 X{global.hepaFan}
    M291 R"Succes" P"Test completed successfully!" S2

    
    